function [M, V, B, G] = update_matrix(m, L, g, N, Ir, Bl, Br, theta1, theta2, omega1, omega2)
% 更新动力学矩阵
% M为广义质量矩阵，V为耦合系数矩阵，B为阻尼系数矩阵，G为空间重力矩阵

M = [m*L^2*(3 + 2*cos(theta2)) + Ir*(N^2), m*(L^2)*(1 + cos(theta2)); m*(L^2)*(1 + cos(theta2)), m*(L^2) + Ir*(N^2)];
 
V = [0, (m * (L^2) * (2*omega1 + omega2)*sin(theta2)); (m * (L^2) * omega1 * sin(theta2)), 0];
 
B = [Bl+Br*(N^2), 0; 0, Bl+Br*(N^2)];
 
G = [2*m*g*L*cos(theta1) + m*g*L*cos(theta1+theta2); m*g*L*cos(theta1+theta2)];